<template>
	<view>
		<!-- 注意，如果需要兼容微信小程序，最好通过setRules方法设置rules规则 -->
		<u--form labelPosition="left" :model="model1" :rules="rules" ref="form1">
			<u-form-item label="快递单号" prop="userInfo.logistic" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.logistic" border="none"></u--input>
			</u-form-item>
			<u-form-item label="快递名称" prop="userInfo.name" borderBottom @click="showSex = true;" ref="item1">
				<u--input v-model="model1.userInfo.name" disabled disabledColor="#ffffff" placeholder="请选择快递名称"
					border="none"></u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
		</u--form>
		<u-action-sheet :show="showSex" :actions="actions" title="请选择快递名称" @close="showSex = false" @select="sexSelect">
		</u-action-sheet>
		<u-button type="error" @tap="query">物流查询</u-button>	
		<span style="color: #8F8F94;">{{oldlogistic}}</span>
	</view>
</template>
<script>
	export default {
		// 测试快递单号  780098068058
		data() {
			return {
				showSex: false,
				model1: {
					userInfo: {
						logistic: '',
						name: '',
					},
				},
				actions: [{
						name: '邮政',
					},
					{
						name: '申通',
					},
					{
						name: '顺丰',
					},
				],
				rules: {
					'userInfo.name': {
						type: 'string',
						required: true,
						message: '请填写快递单号',
						trigger: ['blur', 'change']
					},
					'userInfo.sex': {
						type: 'string',
						max: 1,
						required: true,
						message: '请选择快递名称',
						trigger: ['blur', 'change']
					},
				},
				radio: '',
				switchVal: false,
				content:[],
				oldlogistic:[],

			};
		},
		methods: {
			sexSelect(e) {
				this.model1.userInfo.name = e.name
				this.$refs.form1.validateField('userInfo.name')
			},
			query() {
				this.oldlogistic.push(this.model1.userInfo.logistic)
				uni.request({
					url: "http://localhost:9009/api/logistics/logistics",
					data: {
						logistic: this.model1.userInfo.logistic
					},
					success: (res) => {
						console.log(res)
						console.log(res.data.data.data)
						this.content=res.data.data.data
						uni.navigateTo({
							url:"../about/about?result="+this.content
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
